export default {
    namespaced: true,
    state: {
        editorVisble: false,
        content: "",
    },
    actions: {
        submitEditedContent(context, value) {
            // console.log(value)
            if (!value) return;//undefined和null都是false
            const reg = /<p>(?<content>.*)<\/p>/;
            const result = reg.exec(value);
            // console.log(result)
            if (result && result.groups) {
                context.commit("SET_CONTENT", result.groups.content)
            }
        }
    },
    mutations: {
        CHANGE_VISBLE(state) {
            state.editorVisble = !state.editorVisble;
        },
        SET_CONTENT(state, content) {
            state.content = content;
        },
        CLEAR(state) {
            state.content = ""
        }
    }
}